from django.shortcuts import render,redirect,HttpResponse
from django.views import View

users=[
{"name":"张三","address":"北京","phone":"13543434233"},
{"name":"李四","address":"上海","phone":"18843434233"},
{"name":"王五","address":"广州","phone":"16643434233"}]

# Create your views here.
def add(request):
    if request.method=='POST':
        picter = request.POST.get('picter')#获取照片
        name = request.POST.get('name')#获取昵称
        city = request.POST.get('city')#获取城市
        sex = request.POST.get('sex')#获取性别
        qm = request.POST.get('qm')#获取个性签名
        return HttpResponse('成功')
    return render(request, 'add.html')#返回添加页面
def show(request):
    return render(request, 'add.html')#获取表单所有内容
def allUser(request):
    data=users
    return render(request,'index.html',{'data':data})

# def student(request):
#         name=request.POST.get('name')
#         classname=request.POST.get('classname')
#         cardid=request.POST.get('cardid')
#         phone=request.POST.get('phone')
#
#         stu=Student(name=name,classname=classname,cardid=cardid,phone=phone)
#         stu.save()
def tm(request):
    if request.method=='POST':
        lx=request.POST.get('lx')
        name=request.POST.get('name')
        miaoshu=request.POST.get('miaoshu')
        biaoqian=request.POST.get('biaoqian')
        tigai=request.POST.get('tigai')
        address=request.POST.get('address')
        cd=request.POST.get('cd')
        Tm.object.create(lx=lx,name=name,miaoshu=miaoshu,biaoqian=biaoqian,tigai=tigai,address=address,cd=cd)
        return render(request,'add.html')
    return redirect('book:show')